package com.semlab.client.widgets;

import com.google.gwt.user.client.ui.*;
import com.semlab.client.bundle.Resources;

/**
 * @author Slobodan
 */
public class PropertyTableInline extends Composite {
    private FlowPanel container = new FlowPanel();

    public PropertyTableInline() {
        initWidget(container);
    }

    public void insertWidget(String key, Widget widget) {
        widget.addStyleName(Resources.INSTANCE.css().propertyTableInlineValue());
        HorizontalPanel panel = new HorizontalPanel();
        Label label = new Label(key.concat(":"));
        label.addStyleName(Resources.INSTANCE.css().propertyTableInlineKey());
        panel.add(label);
        WidgetUtils.glue(panel, "10px");
        panel.add(widget);
        container.add(panel);
        panel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_MIDDLE);
        panel.setCellVerticalAlignment(widget, HasVerticalAlignment.ALIGN_MIDDLE);
    }
    public void insertWidget(String key, String value) {
        insertWidget(key, new Label(value));
    }

    public void clear() {
        container.clear();
    }
}
